<!DOCTYPE html>
<html lang="en">
  <head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  <meta content="" name="keywords">

  <title> 奇淫技巧 - </title>
  <meta name="description" content="" />
  <meta property="og:title" content="奇淫技巧" />
  <meta name="twitter:title" content="奇淫技巧" />
  <meta name="author" content="{Description { .Site.Author.name }}"/>
  <meta name="twitter:card" content="summary" />
  <meta property="og:url" content="https://systemime.github.io/series/%E5%A5%87%E6%B7%AB%E6%8A%80%E5%B7%A7/" />
  <meta property="og:type" content="website" />
  <meta property="og:site_name" content="听风的小站" />

  <meta name="generator" content="Hugo 0.67.0" />
  <link rel="canonical" href="https://systemime.github.io/series/%E5%A5%87%E6%B7%AB%E6%8A%80%E5%B7%A7/" />
  <link rel="alternate" href="https://systemime.github.io/index.xml" type="application/rss+xml" title="听风的小站">
  <script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/jquery-1.12.4.min.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css" integrity="sha384-wITovz90syo1dJWVh32uuETPVEtGigN07tkttEqPv+uR2SE/mbQcG7ATL28aI9H0" crossorigin="anonymous">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  
  
  <link rel="stylesheet" href="https://systemime.github.io/css/main.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/my.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/pace.css" />
  <link rel="stylesheet" href="https://cdn.plyr.io/3.4.7/plyr.css">
  <link rel="stylesheet" href="https://systemime.github.io/css/lightgallery.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/baguetteBox.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/search.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/reward.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/share.min.css" />
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic" />
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" />
  <link rel="stylesheet" href="https://systemime.github.io/css/pygment_highlights.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/highlight.min.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/toc.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/lightbox.css" />
  <link rel="stylesheet" href="https://systemime.github.io/live2d/css/live2d.css" />
  
  <link href="https://systemime.github.io/css/video-js.css" rel="stylesheet">


<meta name="baidu-site-verification" content="g8IYR9SNLF" />
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?cffe439e37449bb1c07ab26ab56484bb";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

<link rel="stylesheet" href="https://systemime.github.io/css/prism.css" />









<script src="https://systemime.github.io/js/pace.min.js" data-no-instant></script>



<script src="https://systemime.github.io/js/instantclick.min.js" data-no-instant></script>
   <script data-no-instant>
   InstantClick.on('change', function(isInitialLoad) {
     if (isInitialLoad === false) {
       if (typeof MathJax !== 'undefined') 
         MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
       if (typeof prettyPrint !== 'undefined') 
         prettyPrint();
       if (typeof _hmt !== 'undefined')  
         _hmt.push(['_trackPageview', location.pathname + location.search]);
       if (typeof ga !== 'undefined')  
           ga('send', 'pageview', location.pathname + location.search);
     }
   });
   InstantClick.init();
</script>




<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/gist-embed/2.7.1/gist-embed.min.js"></script>


<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
  (adsbygoogle = window.adsbygoogle || []).push({
    google_ad_client: "ca-pub-3925981084585036",
    enable_page_level_ads: true
  });
</script>



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/photoswipe/4.1.1/photoswipe.min.css" integrity="sha256-sCl5PUOGMLfFYctzDW3MtRib0ctyUvI9Qsmq2wXOeBY=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/photoswipe/4.1.1/default-skin/default-skin.min.css" integrity="sha256-BFeI1V+Vh1Rk37wswuOYn5lsTcaU96hGaI7OUVCLjPc=" crossorigin="anonymous" />



<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

<div class="pswp__bg"></div>

<div class="pswp__scroll-wrap">
    
    <div class="pswp__container">
      <div class="pswp__item"></div>
      <div class="pswp__item"></div>
      <div class="pswp__item"></div>
    </div>
    
    <div class="pswp__ui pswp__ui--hidden">
    <div class="pswp__top-bar">
      
      <div class="pswp__counter"></div>
      <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
      <button class="pswp__button pswp__button--share" title="Share"></button>
      <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
      <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
      
      
      <div class="pswp__preloader">
        <div class="pswp__preloader__icn">
          <div class="pswp__preloader__cut">
            <div class="pswp__preloader__donut"></div>
          </div>
        </div>
      </div>
    </div>
    <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
      <div class="pswp__share-tooltip"></div>
    </div>
    <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
    </button>
    <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
    </button>
    <div class="pswp__caption">
      <div class="pswp__caption__center"></div>
    </div>
    </div>
    </div>
</div>

</head>

  <body>
    <nav class="navbar navbar-default navbar-fixed-top navbar-custom">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-navbar">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="https://systemime.github.io">听风的小站</a>
    </div>
    <div class="collapse navbar-collapse" id="main-navbar">
      <ul class="nav navbar-nav navbar-right">
        
          
            <li>
		    <a title="博客" href="https://systemime.github.io/blog/">博客</a>
              
              
            </li>
          
        
          
            <li>
		    <a title="片刻" href="https://systemime.github.io/moment/">片刻</a>
              
              
            </li>
          
        
          
            <li>
		    <a title="关于" href="https://systemime.github.io/about/">关于</a>
              
              
            </li>
          
        
          
            <li>
		    <a title="留言" href="https://systemime.github.io/message/">留言</a>
              
              
            </li>
          
        

        

        
        
      </ul>
    </div>

    <div class="avatar-container">
      <div class="avatar-img-border">
        
      </div>
    </div>

  </div>
</nav>






    
  <header class="header-section ">
    <div class="intro-header no-img">
      <div class="container">
        <div class="row">
          <div class="col-lg-12 col-md-12 col-md-offset-0">
            <div class="page-heading">
              <h1>#奇淫技巧</h1>
              <hr class="small">
            </div>
          </div>
        </div>
      </div>
    </div>
  </header>

    
  <div class="container" role="main">
    <div class="row">
      <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
        
        <div class="posts-list">
          
            <article class="post-preview">
              <a href="https://systemime.github.io/blog/2019-08/django%E8%A7%A3%E5%86%B3%E8%B7%A8%E5%9F%9F%E9%97%AE%E9%A2%98/">
                <h2 class="post-title">Django解决跨域问题</h2>

                
              </a>

              <p class="post-meta">
                Posted on August 5, 2019
              </p>
              <div class="post-entry">
                
                  <h2 id="一错误提示">一、错误提示</h2>
<pre><code>No 'Access-Control-Allow-Origin' header is present on the requested resource.
</code></pre><h3 id="什么是cors">什么是CORS</h3>
<p>上面的问题就是由<code>CORS</code>引起的，什么是CORS?<br>
CORS（跨域资源共享，Cross-Origin Resource Sharing）是一种跨域访问的机制，可以让Ajax实现跨域访问。<br>
其实，在服务器的response header中，加入 &quot; Access-Control-Allow-Origin: *&rdquo; 即可支持CORS</p>
<h2 id="二跨域方案">二、跨域方案</h2>
<h3 id="1使用jsonp">1、使用JSONP</h3>
<p>使用Ajax获取json数据时，存在跨域的限制。</p>
<p>不过，在Web页面上调用js的script脚本文件时却不受跨域的影响，JSONP就是利用这个来实现跨域的传输。</p>
<p>因此，我们需要将Ajax调用中的dataType从JSON改为JSONP（相应的API也需要支持JSONP）格式。</p>
<p><strong>JSONP只能用于GET请求。</strong></p>
<h3 id="2直接修改django中的viewspy文件">2、直接修改Django中的views.py文件</h3>
<p>修改views.py中对应API的实现函数，允许其他域通过Ajax请求数据：
<div class="highlight"><pre class="chroma"><code class="language-python" data-lang="python"><span class="k">def</span> <span class="nf">myview</span><span class="p">(</span><span class="n">_request</span><span class="p">):</span>
  <span class="n">response</span> <span class="o">=</span> <span class="n">HttpResponse</span><span class="p">(</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">({</span><span class="s2">&#34;key&#34;</span><span class="p">:</span> <span class="s2">&#34;value&#34;</span><span class="p">,</span> <span class="s2">&#34;key2&#34;</span><span class="p">:</span> <span class="s2">&#34;value&#34;</span><span class="p">}))</span>
  <span class="n">response</span><span class="p">[</span><span class="s2">&#34;Access-Control-Allow-Origin&#34;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&#34;*&#34;</span>
  <span class="n">response</span><span class="p">[</span><span class="s2">&#34;Access-Control-Allow-Methods&#34;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&#34;POST, GET, OPTIONS&#34;</span>
  <span class="n">response</span><span class="p">[</span><span class="s2">&#34;Access-Control-Max-Age&#34;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&#34;1000&#34;</span>
  <span class="n">response</span><span class="p">[</span><span class="s2">&#34;Access-Control-Allow-Headers&#34;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&#34;*&#34;</span>
  <span class="k">return</span> <span class="n">response</span></code></pre></div></p>
<h3 id="3安装django-cors-headers">3、安装django-cors-headers</h3>
<p>来自GitHub的库，<a href="https://github.com/ottoyiu/django-cors-headers/">django-cors-headers</a></p>
<p>用于处理跨源资源共享（CORS）所需的服务器头的Django应用程序</p>
<p>使用之前要注意一下使用范围：
* 支持Python 3.5-3.7
* Django 1.11-2.2支持</p>
<p>安装django-cors-headers：</p>
<pre><code>pip install django-cors-headers
</code></pre><p>必要的添加，在<code>setting.py</code>文件中</p>
<pre><code>INSTALLED_APPS = (
  ...
  'corsheaders',
  ...
)
 
...
 
MIDDLEWARE_CLASSES = (
  ...
  'corsheaders.middleware.CorsMiddleware',
  'django.middleware.common.CommonMiddleware',
  ...
)
</code></pre><p>分享一下个人的其他配置(如果有安全性考虑请不要照抄，尤其是第一行&hellip;.)，具体请看GitHub官方配置页</p>
<pre><code># 跨域设置
CORS_ORIGIN_ALLOW_ALL = True
CORS_ORIGIN_WHITELIST = []
CORS_ALLOW_METHODS = [
    ' DELETE ',
    ' GET ',
    ' OPTIONS ',
    ' PATCH ',
    ' POST ',
    ' PUT ',
]
CORS_ALLOW_HEADERS = [
    'accept',
    'accept-encoding',
    'authorization',
    'content-type',
    'dnt',
    'origin',
    'user-agent',
    'x-csrftoken',
    'x-requested-with',
]
CORS_ALLOW_CREDENTIALS = True

X_FRAME_OPTIONS = 'ALLOWALL'

SECURE_HSTS_SECONDS = 3600
</code></pre><h2 id="ajax提交的小教程">ajax提交的小教程</h2>
<p><a href="https://www.cnblogs.com/wj-1314/p/10539203.html">https://www.cnblogs.com/wj-1314/p/10539203.html</a></p>

                
              </div>

              
                <span class="post-meta">
                  
                    #<a href="https://systemime.github.iotags/django/">Django</a>&nbsp;
                  
                    #<a href="https://systemime.github.iotags/%E8%B7%A8%E5%9F%9F/">跨域</a>&nbsp;
                  
                </span>
              

            </article>
          
            <article class="post-preview">
              <a href="https://systemime.github.io/blog/2019-07/centos7.4%E5%BF%98%E8%AE%B0%E5%AF%86%E7%A0%81%E6%80%8E%E4%B9%88%E5%8A%9E/">
                <h2 class="post-title">Centos7.4忘记密码怎么办</h2>

                
              </a>

              <p class="post-meta">
                Posted on July 26, 2019
              </p>
              <div class="post-entry">
                
                  <p><strong>注：CentOS 7 root密码的重置方式和CentOS 6完全不一样。</strong></p>
<h2 id="一重启开机">一、重启开机</h2>
<p>在开机界面按<code>e</code>，进入编辑页面</p>
<p><img src="" alt="首页"></p>
<p>编辑界面如下图：</p>
<p><img src="" alt="编辑界面"></p>
<h2 id="二编辑">二、编辑</h2>
<p>将linux16那段文字中的<code>ro</code>改为<code>rw</code>，在末尾追加<code>init/bin/sh</code>，如下图所示：<!-- raw HTML omitted --><br>
<img src="" alt="修改"></p>
<p>接下来快捷键<code>CTRL+x</code>进行重启</p>
<h2 id="三修改密码">三、修改密码</h2>
<p>在这个画面出现的时候输入命令</p>
<pre><code>echo &quot;你的密码&quot;|passwd --stdin root
# root也可以替换成其他用户名
</code></pre><p><img src="" alt="修改密码"></p>
<h2 id="四更新信息">四、更新信息</h2>
<p>由于selinux开启着，我们需要执行以下命令更新系统信息，否则重启后密码未生效</p>
<pre><code>touch /.autorelabel
</code></pre><p>执行后再执行下面代码重启</p>
<pre><code>exec /sbin/init
</code></pre><p>重启过程中可能伴随卡顿，或黑屏一段时间，请耐心等待</p>
<h2 id="五验证">五、验证</h2>
<p>接下来正常启动后输入密码验证登录即可</p>

                
              </div>

              
                <span class="post-meta">
                  
                    #<a href="https://systemime.github.iotags/centos/">centos</a>&nbsp;
                  
                    #<a href="https://systemime.github.iotags/%E6%89%BE%E5%9B%9E%E5%AF%86%E7%A0%81/">找回密码</a>&nbsp;
                  
                </span>
              

            </article>
          
            <article class="post-preview">
              <a href="https://systemime.github.io/blog/2019-07/centos7%E9%85%8D%E7%BD%AEsnmp-%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE%E7%AF%87/">
                <h2 class="post-title">Centos7配置snmp 基础配置篇</h2>

                
              </a>

              <p class="post-meta">
                Posted on July 25, 2019
              </p>
              <div class="post-entry">
                
                  <h2 id="安装snmp">安装SNMP</h2>
<pre><code>yum install -y net-snmp net-snmp-utils
</code></pre><h2 id="查看是否安装成功">查看是否安装成功</h2>
<pre><code>rpm -qa | grep snmp
</code></pre><h2 id="启动snmp服务">启动snmp服务</h2>
<ul>
<li>在centos6及以前
<pre><code>service snmpd stop/start/ststus
</code></pre></li>
<li>在centos7以后
<pre><code>systemctl start/stop/status snmp.service
</code></pre></li>
</ul>
<h2 id="设置自启动">设置自启动</h2>
<ul>
<li>在centos6及以前
<pre><code>chkconfig snmpd on
</code></pre></li>
<li>在centos7以后
<pre><code>systemctl enable snmpd.service
</code></pre></li>
</ul>
<h2 id="查看是否配置自启成功">查看是否配置自启成功</h2>
<ul>
<li>在centos6及以前
<pre><code>chkconfig --list | grep snmpd
</code></pre></li>
<li>在centos7以后
<pre><code>systemctl list-unit-files snmpd.service
</code></pre></li>
</ul>
<h2 id="测试服务">测试服务</h2>
<ul>
<li>使用<code>snmpwalk</code>命令查看本机localhost的主机名
<pre><code>snmpwalk -v 2c -c public localhost sysName.0
</code></pre><p>输出：</p>
<pre><code>SNMPv2-MIB::sysName.0 = STRING: localhost.localdomain
</code></pre></li>
<li>使用<code>snmptranslate</code>命令验证snmp工具是否可以使用
<pre><code>[cc@localhost ~]$ snmptranslate -To | head
.1.3
.1.3.6
.1.3.6.1
.1.3.6.1.1
.1.3.6.1.2
.1.3.6.1.2.1
.1.3.6.1.2.1.1
.1.3.6.1.2.1.1.1
.1.3.6.1.2.1.1.2
.1.3.6.1.2.1.1.3
</code></pre><p>如上，查出了部分oid，则表示snmp工具可以正常使用。</p>
</li>
<li>测试远程主机是否可以获取数据<br>
在另一台初主机上配置同样的snmp，然后使用第一步验证中的方法
<pre><code>snmpwalk -v 2c -c public 远程IP sysName.0
</code></pre></li>
</ul>
<h2 id="配置snmp服务">配置snmp服务</h2>
<p>以上安装完成后，使用的是<code>snmp</code>的默认配置，通过这些默认配置，我们只能获取主机的部分信息。但一些其他的重要信息，无法获取。如主机的CPU使用情况，内存使用情况等。</p>
<p>**注<code>OID</code>：**SNMP对象标识符(OID)是定义在特定MIB模式中的值，来定义一个特定的在MIB数据库中SNMP目标。SNMP OID是划界序列数字组成a.b.c&hellip;x.y.z的周期。它对信息的一个项目是一个独特的标识符，其是一个MIB的一部分。典型的OIDs能够有与它们相关的名字。OIDs在自然中是分等级的。因此1.2.3出现在1.3之前但是在1.2之后。OID前面的一部分是由协会分配的，每个企业都有自己的Oid标识</p>
<p><strong>常见OID：<a href="https://blog.csdn.net/a9254778/article/details/51200502">SNMP监控一些常用OID</a></strong></p>
<p>这时候，若要获取主机的一些重要信息，则要修改<code>snmp</code>的默认配置。<br>
配置方法：修改<code>/etc/snmp/snmpd.conf</code>文件</p>
<ol>
<li>
<p><strong>修改查看设备节点权限</strong><br>
在该文件中，<code>view</code>定义了可以查看哪些节点设备的信息，参考上面的文章，我们可以发现默认的<code>view</code>部分如下</p>
<pre><code>####
# Third, create a view for us to let the group have rights to:
   
# Make at least  snmpwalk -v 1 localhost -c public system fast again.
#       name           incl/excl     subtree         mask(optional)
view    systemview    included   .1.3.6.1.2.1.1
view    systemview    included   .1.3.6.1.2.1.25.1.1
</code></pre><p>参考上面的链接文章，我们可以看到默认允许查看<strong>系统参数</strong>这些基本的信息，而主机CPU和内存等设备都不在这些节点下，所以无法获取这些数据。<br>
为了方便，我们可以添加这么一行</p>
<pre><code>view systemview included .1
# 表示可以查看.1节点下的所有设备信息。
# 这样就包括系统参数、网络接口、CPU及负载、内存磁盘等信息
</code></pre></li>
<li>
<p><strong>修改Process checks的配置</strong><br>
在vim编辑模式下，搜索<code>Process checks</code>，将</p>
<pre><code># proc mountd
# proc ntalkd 4
# proc sendmail 10 1
</code></pre><p>三行前的“#”号去掉，取消注释.</p>
<p>代码含义解释：</p>
<pre><code>1234/5000
＃进程检查。
＃
＃以下是如何使用代理进行检查的示例
＃进程在主机上运行。语法类似于：
＃
#proc NAME [MAX = 0] [MIN = 0]
＃
#NAME：要检查的进程的名称。它必须匹配
#fully（即，http将找不到httpd进程）。
#MAX：允许运行的最大数量。默认为0。
#MIN：要运行的最小数量。默认为0。

＃
＃Examples（默认注释掉）：
   
＃确保mountd正在运行
proc mountd

＃确保运行的ntalkds不超过4个，但0也可以。
proc ntalkd 4

＃确保至少有一个sendmail，但小于或等于10正在运行。
proc sendmail 10 1
</code></pre></li>
<li>
<p><strong>修改Executables/scripts配置</strong>
将</p>
<pre><code>#exec echotest /bin/echo hello world
</code></pre><p>一行前的“#”号去掉，取消注释。</p>
<p>代码含义解释</p>
<pre><code>###############################################################################
# Executables/scripts
# 可执行文件/脚本
#

#
#  You can also have programs run by the agent that return a single
#  您还可以让代理运行的程序返回单个程序
#  line of output and an exit code.  Here are two examples.
#  输出行和退出代码。这是两个例子。
   
#  exec NAME PROGRAM [ARGS ...]
#
#  NAME:     A generic name. The name must be unique for each exec statement.
             通用名称。每个exec语句的名称必须是唯一的。
#  PROGRAM:  The program to run.  Include the path!
             要运行的程序。包括路径！
#  ARGS:     optional arguments to be passed to the program
             要传递给程序的可选参数

# a simple hello world
</code></pre><p>``</p>
</li>
<li>
<p><strong>修改disk checks配置</strong>
将</p>
<pre><code>#disk / 10000
</code></pre><p>一行前的“#”号去掉，取消注释。</p>
<p>代码含义解释：</p>
<pre><code>#disk check
＃

＃代理可以检查可用磁盘空间量，并制作
＃确定它高于设定的限制。

#disk PATH [MIN = 100000]
＃
#PATH：挂载相关磁盘的路径。
#MIN：空间低于此值的磁盘将设置Mib的errorFlag。
＃默认值= 100000。

＃检查/分区并确保它至少包含10兆。
</code></pre><p>``</p>
</li>
<li>
<p><strong>修改load average checks配置</strong></p>
<pre><code>#load 12 14 14
</code></pre><p>一行前的“#”号去掉，取消注释。</p>
<p>代码含义解释：</p>
<pre><code>#load average check
＃

#load [1MAX = 12.0] [5MAX = 12.0] [15MAX = 12.0]
＃
＃1MAX：如果查询时1分钟的平均负载超过此限制
#time，将设置errorFlag。
＃5MAX：相似，但平均为5分钟。
＃15MAX：相似，但平均为15分钟。

＃检查负载：
</code></pre><p>``</p>
</li>
<li>
<p><strong>保存修改，重启snmp服务</strong></p>
<ul>
<li>在centos6及以前
<pre><code>service snmpd restart
</code></pre></li>
<li>在centos7以后
<pre><code>systemctl restart snmpd.service
</code></pre></li>
</ul>
</li>
<li>
<p><strong>验证修改后配置</strong>
即，测试一下之前不能访问的信息现在能不能访问</p>
<pre><code>snmpwalk -v 2c -c public localhost 1.3.6.1.4.1.2021.11.11.0
</code></pre><p>输出内容</p>
<pre><code>[root@localhost ~]# snmpwalk -v 2c -c public localhost 1.3.6.1.4.1.2021.11.11.0UCD-SNMP-MIB::ssCpuIdle.0 = INTEGER: 98
[root@localhost ~]# snmpwalk -v 2c -c public localhost 1.3.6.1.4.1.2021.11.9.0
UCD-SNMP-MIB::ssCpuUser.0 = INTEGER: 0
[root@localhost ~]# snmpwalk -v 2c -c public localhost .1.3.6.1.2.1.25.2.2.0
HOST-RESOURCES-MIB::hrMemorySize.0 = INTEGER: 7994076 KBytes
</code></pre></li>
</ol>
<h2 id="可选的操作">可选的操作</h2>
<h3 id="修改可信任的登录名">修改可信任的登录名</h3>
<p>配置文件如下位置：</p>
<pre><code># As shipped, the snmpd demon will only respond to queries on the
# system mib group until this file is replaced or modified for
# security purposes.  Examples are shown below about how to increase the
# level of access.

# By far, the most common question I get about the agent is &quot;why won't
# it work?&quot;, when really it should be &quot;how do I configure the agent to
# allow me to access it?&quot;
#
# By default, the agent responds to the &quot;public&quot; community for read
# only access, if run out of the box without any configuration file in 
# place.  The following examples show you other ways of configuring
# the agent so that you can change the community names, and give
# yourself write access to the mib tree as well.
#
# For more information, read the FAQ as well as the snmpd.conf(5)
# manual page.

####
# First, map the community name &quot;public&quot; into a &quot;security name&quot;

#       sec.name  source          community
com2sec notConfigUser  default       public
</code></pre><p>解释如下：</p>
<pre><code>＃出厂时，snmpd只响应系统mib组上的查询，直到为安全目的替换或修改此文件。 下面显示了有关如何提高访问级别的示例。

＃到目前为止，我对代理商最常见的问题是“为什么它不起作用？”，真的应该是“如何配置代理以允许我访问它？”
＃
＃默认情况下，代理响应“公共”社区以进行只读访问，如果在没有任何配置文件的情况下开箱即用。 以下示例显示了配置代理的其他方法，以便您可以更改社区名称，并为自己提供对mib树的写入权限。
＃
＃有关更多信息，请阅读FAQ以及snmpd.conf（5）手册页。

####
＃首先，将社区名称“public”映射到“安全名称”

com2sec notConfigUser 默认 公共

</code></pre><p>这部分修改其实很简单，修改public为你想要的名称即可</p>
<h3 id="紧接上一条">紧接上一条</h3>
<p>在上一条配置文件的下一行，你将看到后面的几步</p>
<pre><code>####
# Second, map the security name into a group name:

#       groupName      securityModel securityName
group   notConfigGroup v1           notConfigUser
group   notConfigGroup v2c           notConfigUser

####
# Third, create a view for us to let the group have rights to:

# Make at least  snmpwalk -v 1 localhost -c public system fast again.
#       name           incl/excl     subtree         mask(optional)
view    systemview    included   .1.3.6.1.2.1.1
view    systemview    included   .1.3.6.1.2.1.25.1.1
view    systemview    included   .1
####
# Finally, grant the group read-only access to the systemview view.

#       group          context sec.model sec.level prefix read   write  notif
access  notConfigGroup &quot;&quot;      any       noauth    exact  systemview none none
</code></pre><p><strong>Third</strong> 已经在本文第一部分解释，下面是对<strong>Finally</strong> 的解释</p>
<pre><code>####
# Second，将安全名称映射到组名：

#       组名           安全模型      安全名
group   notConfigGroup v1            notConfigUser
group   notConfigGroup v2c           notConfigUser

####
# Finally, 授予组对systemview视图的只读访问权限.

#       group          context sec.model sec.level prefix read       write  notif
access  notConfigGroup &quot;&quot;      any       noauth    exact  systemview none   none
</code></pre><p>这里要修改的就是<strong>Finally</strong>部分权限设置，把 <code>systemview</code> 改为 <code>all</code></p>

                
              </div>

              
                <span class="post-meta">
                  
                    #<a href="https://systemime.github.iotags/linux/">Linux</a>&nbsp;
                  
                    #<a href="https://systemime.github.iotags/snmp/">snmp</a>&nbsp;
                  
                    #<a href="https://systemime.github.iotags/systemctl/">systemctl</a>&nbsp;
                  
                </span>
              

            </article>
          
            <article class="post-preview">
              <a href="https://systemime.github.io/blog/2019-07/linux-%E6%89%B9%E9%87%8F%E6%9F%A5%E6%89%BE%E6%96%87%E4%BB%B6%E5%86%85%E5%AE%B9/">
                <h2 class="post-title">Linux 批量查找文件内容</h2>

                
              </a>

              <p class="post-meta">
                Posted on July 24, 2019
              </p>
              <div class="post-entry">
                
                  <h2 id="linux查找文件内容的常用命令方法">Linux查找文件内容的常用命令方法。</h2>
<h4 id="从文件内容查找匹配指定字符串的行">从文件内容查找匹配指定字符串的行：</h4>
<pre><code>$ grep &quot;被查找的字符串&quot; 文件名
</code></pre><ul>
<li>例子：在当前目录里第一级文件夹中寻找包含指定字符串的.in文件</li>
</ul>
<pre><code>grep &quot;thermcontact&quot; */*.in
</code></pre><h4 id="从文件内容查找与正则表达式匹配的行">从文件内容查找与正则表达式匹配的行：</h4>
<pre><code>$ grep –e “正则表达式” 文件名
</code></pre><h4 id="查找时不区分大小写">查找时不区分大小写：</h4>
<pre><code>$ grep –i &quot;被查找的字符串&quot; 文件
</code></pre><h4 id="查找匹配的行数">查找匹配的行数：</h4>
<pre><code>$ grep -c &quot;被查找的字符串&quot; 文件名
</code></pre><h4 id="从文件内容查找不匹配指定字符串的行">从文件内容查找不匹配指定字符串的行：</h4>
<pre><code>$ grep –v &quot;被查找的字符串&quot; 文件名
</code></pre><h4 id="查找符合条件后缀文件及内容">查找符合条件后缀文件及内容</h4>
<ul>
<li>从根目录开始查找所有扩展名为.log的文本文件，并找出包含”ERROR”的行</li>
</ul>
<pre><code>find / -type f -name &quot;*.log&quot; | xargs grep &quot;ERROR&quot;
</code></pre><ul>
<li>从当前目录开始查找所有扩展名为.in的文本文件，并找出包含”thermcontact”的行</li>
</ul>
<pre><code>find . -name &quot;*.in&quot; | xargs grep &quot;thermcontact&quot;
</code></pre>
                
              </div>

              
                <span class="post-meta">
                  
                    #<a href="https://systemime.github.iotags/linux/">Linux</a>&nbsp;
                  
                    #<a href="https://systemime.github.iotags/%E6%9F%A5%E6%89%BE/">查找</a>&nbsp;
                  
                </span>
              

            </article>
          
        </div>
        
          <ul class="pager main-pager">
            
              <li class="previous">
                <a href="https://systemime.github.io/series/%E5%A5%87%E6%B7%AB%E6%8A%80%E5%B7%A7/page/1">&larr; Newer Posts</a>
              </li>
            
            
              <li class="next">
                <a href="https://systemime.github.io/series/%E5%A5%87%E6%B7%AB%E6%8A%80%E5%B7%A7/page/3">Older Posts &rarr;</a>
              </li>
            
          </ul>
        
      </div>
    <div align="center" class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
        

<ul class="pagination">
    
    <li class="page-item">
        <a href="https://systemime.github.io/series/%E5%A5%87%E6%B7%AB%E6%8A%80%E5%B7%A7/" class="page-link" aria-label="First"><span aria-hidden="true">&laquo;&laquo;</span></a>
    </li>
    
    <li class="page-item">
    <a href="https://systemime.github.io/series/%E5%A5%87%E6%B7%AB%E6%8A%80%E5%B7%A7/" class="page-link" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a>
    </li>
    
    
    
    
    
    
    
        
        
    
    
    <li class="page-item"><a class="page-link" href="https://systemime.github.io/series/%E5%A5%87%E6%B7%AB%E6%8A%80%E5%B7%A7/">1</a></li>
    
    
    
    
    
    
        
        
    
    
    <li class="page-item active"><a class="page-link" href="https://systemime.github.io/series/%E5%A5%87%E6%B7%AB%E6%8A%80%E5%B7%A7/page/2/">2</a></li>
    
    
    
    
    
    
        
        
    
    
    <li class="page-item"><a class="page-link" href="https://systemime.github.io/series/%E5%A5%87%E6%B7%AB%E6%8A%80%E5%B7%A7/page/3/">3</a></li>
    
    
    
    
    
    
        
        
    
    
    <li class="page-item disabled"><span aria-hidden="true">&nbsp;&hellip;&nbsp;</span></li>
    
    
    
    
    
    
        
        
    
    
    
    
    
    
    
        
        
    
    
    <li class="page-item"><a class="page-link" href="https://systemime.github.io/series/%E5%A5%87%E6%B7%AB%E6%8A%80%E5%B7%A7/page/6/">6</a></li>
    
    
    <li class="page-item">
    <a href="https://systemime.github.io/series/%E5%A5%87%E6%B7%AB%E6%8A%80%E5%B7%A7/page/3/" class="page-link" aria-label="Next"><span aria-hidden="true">&raquo;</span></a>
    </li>
    
    <li class="page-item">
        <a href="https://systemime.github.io/series/%E5%A5%87%E6%B7%AB%E6%8A%80%E5%B7%A7/page/6/" class="page-link" aria-label="Last"><span aria-hidden="true">&raquo;&raquo;</span></a>
    </li>
    
</ul>


        
        
        
        
        
      </div>
    </div>
  </div>

    <div class="rocket"><img src="https://systemime.github.io/img/rocket_up.png" alt="" width="100" height="100"></div>
<script>
    $(function () {
      $(window).scroll(function () {
        
        if ($(window).scrollTop() >= 1000) {
          $('.rocket').stop().fadeIn(1000);
        }else {
          $('.rocket').stop().fadeOut(1000);
        }
      })
      
      $('.rocket').click(function () {
        $('html,body').stop().animate({scrollTop:0},400);
       
      })
    })

</script>

    
    <div id="landlord">
        <div class="message" style="opacity:0"></div>
        <canvas id="live2d" width="280" height="250" class="live2d"></canvas>
        <div class="hide-button">隐藏</div>
    </div>
    
    <footer id="copyright">
  <div class="container">
    <div class="row">
      <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
        <ul class="list-inline text-center footer-links">
          
          
        </ul>
        <p class="credits copyright text-muted">
        &copy;2017-2018
          
          &nbsp;&bull;&nbsp;
          September 20,2019
          updated
          
            &nbsp;&bull;&nbsp;
            <a href="https://systemime.github.io">Home</a>
          
        </p>

        <p class="credits theme-by text-muted">
        <a href="https://servicemesher.github.io" target="_blank">ServiceMesher</a>&nbsp;&bull;&nbsp;<a href="https://github.com/yangchuansheng/k8s-knowledge" target="_blank">Kubernetes 知识图谱</a>
        <br />
        <span id="busuanzi_container_site_pv">
            本站已被访问 <span id="busuanzi_value_site_pv"></span> 次啦
        </span>
        <span id="busuanzi_container_site_uv">
            &ensp;|&ensp;&thinsp;您是第 <span id="busuanzi_value_site_uv"></span> 位到访的小伙伴喔
        </span>
        </p>
        
        <p class="credits theme-by text-muted">
          <a href="http://gohugo.io">Hugo v0.67.0</a> powered &nbsp;&bull;&nbsp; Theme by <a href="http://deanattali.com/beautiful-jekyll/">Beautiful Jekyll</a> adapted to <a href="https://github.com/halogenica/beautifulhugo">Beautiful Hugo</a>
          
          <center><section class="credits theme-by text-muted">
    <span class="footer__copyright">
    <div>
    <span id="span_dt_dt"> </span>
    <script language="javascript">
      function show_date_time(){
        window.setTimeout("show_date_time()", 1000);
        BirthDay=new Date("7/8/2017 10:56:12");
        today=new Date();
        timeold=(today.getTime()-BirthDay.getTime());
        sectimeold=timeold/1000
        secondsold=Math.floor(sectimeold);
        msPerDay=24*60*60*1000
        e_daysold=timeold/msPerDay
        daysold=Math.floor(e_daysold);
        e_hrsold=(e_daysold-daysold)*24;
        hrsold=Math.floor(e_hrsold);
        e_minsold=(e_hrsold-hrsold)*60;
        minsold=Math.floor((e_hrsold-hrsold)*60);
        seconds=Math.floor((e_minsold-minsold)*60);
        span_dt_dt.innerHTML="本博客已经开心运行 "+daysold+" 天 "+hrsold+" 小时 "+minsold+" 分 "+seconds+" 秒";
      }
      show_date_time();
    </script>
    </div>
</script>
</section>
</center>
        </p>
      </div>
    </div>
  </div>
</footer>


<script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/bootstrap.min.js"></script>
<script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/photoswipe-ui-default.min.js"></script>
<script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/photoswipe.min.js"></script>
<script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/auto-render.min.js"></script>
<script src="https://systemime.github.io/js/main.js"></script>
<script src="https://systemime.github.io/js/clipboard.min.js"></script>
<script src="https://systemime.github.io/js/prism.js?t=123"></script>
<script src="https://systemime.github.io/js/highlight.min.js"></script>
<script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/katex.min.js"></script>
<script src="https://systemime.github.io/js/reward.js"></script>
<script src="https://systemime.github.io/js/canvas_ribbon.js"></script>
<script> renderMathInElement(document.body); </script>

<script src="https://systemime.github.io/js/baguetteBox.js"></script>
<script> baguetteBox.run('.gallery');</script>






<script async defer src="https://buttons.github.io/buttons.js"></script>


<script src="https://polyfill.io/v2/polyfill.min.js?features=IntersectionObserver"></script>
<script type="text/javascript" src="https://systemime.github.io/js/quicklink.umd.js"></script>
<script>
window.addEventListener('load', () =>{
   quicklink();
});
</script>



<script type="text/javascript">
 
var a_idx = 0;
jQuery(document).ready(function($) {
    $("body").click(function(e) {
        var a = new Array("Docker", "Kubernetes", "Prometheus", "Envoy", "Istio", "Service Mesh", "Cloud Native");
        var $i = $("<span />").text(a[a_idx]);
        a_idx = (a_idx + 1) % a.length;
        var x = e.pageX,
        y = e.pageY;
        function randomColor() {
          var flakeColor = new Array("#FFDA65", "#00BFFF", "#BA55D3", "#FFA07A", "#87CEEB", "#FFB6C1");
          var snowColor = flakeColor[Math.floor(flakeColor.length * Math.random())];
          return snowColor;
        }
        $i.css({
            "z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
            "top": y - 20,
            "left": x,
            "position": "absolute",
            "font-weight": "bold",
            "color": randomColor()
        });
        $("body").append($i);
        $i.animate({
            "top": y - 180,
            "opacity": 0
        },
        1500,
        function() {
            $i.remove();
        });
    });
});
</script>


<script type="text/javascript" src="https://systemime.github.io/js/lightbox.js"></script>











<script src="https://cdn.plyr.io/3.4.7/plyr.js"></script>
<script>const player = new Plyr('#player');</script>


<script async defer src="https://buttons.github.io/buttons.js"></script>


  </body>
</html>

